#include "Drainage.h"
#include "DrainageSketcher.h"

Drainage::Drainage(){
	this->setType("Drainage");
}

Drainage::Drainage(Position *position) {
	this->position = position;
}

void Drainage::setPosition(Position *position){
	this->position = position;
}

Position *Drainage::getPosition(){
	return this->position;
}

void Drainage::setRadius(float radius){
	this->radius = radius;
}

float Drainage::getRadius(){
	return this->radius;
}

void Drainage::setTexture(Texture *texture){
	this->texture = texture;
}

Texture *Drainage::getTexture(){
	return this->texture;
}

Color * Drainage::getElementColor(){
	return this->elementColor;
}

void Drainage::setElementColor(Color * color){
	this->elementColor = color;
}

Drainage::~Drainage() {
	delete(this->position);
	delete(this->texture);
}

Color * Drainage::getLineColor()
{
	return this->lineColor;
}

void Drainage::setLineColor( Color * color )
{
	this->lineColor = color;
}

void Drainage::draw()
{
	Sketcher* sketcher = new DrainageSketcher(this);
	sketcher->draw();
	delete(sketcher);
}

float Drainage::getMinXPos(){
	return this->getPosition()->getAxisX()-this->radius;
}
	
float Drainage::getMinYPos(){	
	return this->getPosition()->getAxisY()-this->radius;
}
	
float Drainage::getMaxXPos(){	
	return this->getPosition()->getAxisX()+this->radius;
}
	
float Drainage::getMaxYPos(){
	return this->getPosition()->getAxisY()+this->radius;
}

list<Position*> * Drainage::getTrajectory()
{
	return this->trajectory;
}

void Drainage::setTrajectory( list<Position*> * trajectory )
{
	this->trajectory = trajectory;
	this->lastTrajectoryPoint = trajectory->front();
}

void Drainage::move( float timeSameUnitVelocity, float velocityModule )
{
	float movementModule = timeSameUnitVelocity * velocityModule;
	float currentX = this->getPosition()->getAxisX();
	float currentY = this->getPosition()->getAxisY();

	Position * previousPoint = NULL;
	Position * nextPoint = NULL;

	list<Position*>::iterator iterTrajectory;
	iterTrajectory = this->trajectory->begin();
	while(iterTrajectory != this->trajectory->end()) {
		if(*iterTrajectory == lastTrajectoryPoint) {
			iterTrajectory++;
			nextPoint = *iterTrajectory;
			break;
		}
		iterTrajectory++;
	}
	

}